/**
 *
 * @author Anastasiya
 *
 */

#pragma once
#include "algorithm.h"
#include <string>
#include <map>

using namespace std;

class TexWriter;
class TexResultRepresentation;

extern int texWriterInstanceCount;

class TexWriter{

public:
	TexWriter(string algorithmName1, string algorithmName2);
	~TexWriter();
	void addResult(string graphName, TestResult* result1, TestResult* result2);
	void write(string filename);


private:
	string tableHeader;
	string tableContent;

	static const string  TABLE_HEADER_LINE;
	static const string  TABLE_BODY_LINE;
	static const string  HEADER_MULTICOLUMN;
	static const string  ROW_HEADER_MULTICOLUMN;
	static const string  EMPTY_ROW_HEADER_MULTICOLUMN;

	static const string  HEADER_COLUMN_FORMAT;
	static const string  EMPTY_ROW_HEADER_COLUMN_FORMAT;
	static const string  ROW_HEADER_COLUMN_FORMAT;

	static const string  TIME_SUBHEADER_NAME;
	static const string  VERTICES_SUBHEADER_NAME;

	static const string  LATEX_COLUMN_DELIMITER;
	static const string  LATEX_NEWLINE;

	static const string  COLORED_TEXT_BEST_TIME;
	static const string  COLORED_TEXT_BEST_APPROACH;

	static const string  LATEX_BEGIN_DOCUMENT;
	static const string  LATEX_END_DOCUMENT;
	static const string  LATEX_BEGIN_TABLE;
	static const string  LATEX_END_TABLE;

	static const string  LATEX_DOCUMENT_CLASS;
	static const string  LATEX_USE_PACKAGE_FONT;
	static const string  LATEX_USE_PACKAGE_ENCODING;
	static const string  LATEX_USE_PACKAGE_BABEL;
	static const string  LATEX_USE_PACKAGE_MULTIROW;
	static const string  LATEX_USE_PACKAGE_LONGTABLE;
	static const string  LATEX_USE_PACKAGE_COLOR;

	static const string  RIGHT_BRACKET;
	static const string  LEFT_BRACKET;

	static const string  NEW_LINE;



	string generateIncludedPackages();

};

class TexResultRepresentation{
public: TexResultRepresentation(TestResult* result);
		~TexResultRepresentation();
		string getTime();
		string getEdgesCount();

private: string time;
		 string edgesCount;

		 static const string RESULT_NO_TIME;
		 static const string RESULT_NO_EDGES;
		 static const string RESULT_FAILED;
};

const string LATEX_SYMBOL_NUMBER = "\\#";
const string LATEX_SYMBOL_DOLLAR = "\\$";
const string LATEX_SYMBOL_PERCENT = "\\%";
const string LATEX_SYMBOL_AMPERSAND = "\\&";
const string LATEX_SYMBOL_TILDE = "\\~";
const string LATEX_SYMBOL_OPENING_BRACE = "\\{";
const string LATEX_SYMBOL_CLOSING_BRACE = "\\}";
const string LATEX_SYMBOL_UNDERSCORE = "\\_";
const string LATEX_SYMBOL_CARET_CIRCUMFLEX = "\\^";
const string LATEX_SYMBOL_GREATHER = "$>$";
const string LATEX_SYMBOL_LESS = "$<$";
const string LATEX_SYMBOL_BACKSLASH = "$\\backslash$";


static map<char, string> LATEX_RESERVED_CHARS;
static bool latexReservedCharsetInitialized = false;

static void initializeLatexReservedSymbolMap();

string latexString(string input);

